{# Load the tag library #}
{% load bootstrap4 %}

{# 导入多语言 #}
{% load i18n %}

{# Load CSS and JS #}
{% bootstrap_css %}
{% bootstrap_javascript jquery='full' %}

{# Display django.contrib.messages as Bootstrap alers #}
{% bootstrap_messages %}

<!--jobs/templates/base.html-->
<h2>{% translate '浆果科技开放职位' %}</h2>
<p></p>
<hr />

{% block header %}
    <a href="/" style="text-decoration: none; color: #007bff">{% translate 'Homepage' %}</a>
    <a href="/joblist" style="text-decoration: none; color: #007bff">{% translate 'job list' %}</a>
    {% if user.is_authenticated %}
        <a href="/accounts/logout" style="text-decoration: none; color: #007bff">{% translate 'Logout' %}</a>
    {% else %}
        <a href="/accounts/login" style="text-decoration: none; color: #007bff">{% translate 'Login' %}</a>
    {% endif %}

    {% if user.is_authenticated %}
        <p>{% blocktranslate with user_name=user.username %}终于等到你 {{ user_name }}，期待加入我们，用技术去探索一个新世界{% endblocktranslate %}</p>
    {% else %}
        <p>{% translate '欢迎你，期待加入我们，登陆后可以提交简历。' %}</p>
    {% endif %}

    <form action="{% url 'set_language' %}" method="post">
        {% csrf_token %}
        {# redirect_to 是成功选择语言后，会跳转到该页面，默认是首页 #}
        <input type="hidden" name="next" value="{{ redirect_to }}" />
        <select name="language">
            {# 获取当前语言 #}
            {% get_current_language as LANGUAGE_CODE %}
            {# 获取所有可用语言 #}
            {% get_available_languages as LANGUAGES %}
            {% get_language_info_list for LANGUAGES as languages %}
            {% for language in languages %}
                <option value="{{ language.code }}" {% if language.code == LANGUAGE_CODE %}selected{% endif %}>
                    {{ language.name_local }} ({{ language.code }})
                </option>
            {% endfor %}
        </select>
        {% translate "language:" %} {{ LANGUAGE_CODE }}
        <input type="submit" value={% translate "Switch" %} />
    </form>

{% endblock %}

{% block content %}
{% endblock %}
